
-- KEYS[1] {sparta-example}:readable_tab:C4CA4238A0B92382:1680009087660
-- KEYS[2] {sparta-example}:metadata_tab
local members = redis.call('SMembers', KEYS[1])
local result = {}
if members ~= nil then
    local topics = ''
    local tab = {}
    for _, v in pairs(members) do
        local line, _ = string.find(v, ARGV[1])
        topics = topics .. ',' .. v
        if line ~= nil then
            v = string.sub(v, 1, line -1)
        end
        table.insert(tab, v)
    end
    table.insert(result, 1, topics)
    table.insert(result, 2, redis.call('HMGet', KEYS[2], unpack(tab)))
end
return result